<template>
  <div>
    <!-- 设置客户等级可见,当商品开启不同等级可见, 0 关闭、 1 开启 -->
    <el-card v-if="config.open_commodity_visible === 1" class="box-card">
      <div slot="header" class="clearfix">
        <span>设置客户等级可见</span>
      </div>
      <div class="form-container">
        <el-form ref="form" :model="thisForm" label-width="100px" class="demo-ruleForm" size="small">
          <el-form-item label="可见等级：" prop="gradeList">
            <el-checkbox-group v-model="gradeList">
              <el-checkbox
                v-for="item in config.grade_list"
                v-if="item.name"
                :label="item.uuid"
                :key="item.uuid">
                <span>{{ item.name }}</span>
              </el-checkbox>
            </el-checkbox-group>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  mixins: [],
  props: {
    memberConfig: {
      type: Object,
      required: true
    },
    form: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      config: {},
      gradeList: [],
      thisForm: {
        grade_id_list: []
      }
    }
  },
  watch: {
    memberConfig(value) {
      // 会员设置信息
      this.config = value
    },
    form(value) {
      this.thisForm = value
      if (value.grade_id_list) {
        this.gradeList = value.grade_id_list
      }
    }
  },
  methods: {
    // 给父组件传递收取表单的值
    saveMsg() {
      this.$emit('msgEvent', this.gradeList)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .form-container {
    width: 90%;
  }
  .box-card {
    margin-top: 10px;
    margin-bottom: 10px;
  }
  .el-card__body {
    padding: 20px 20px 0 20px!important;
  }
  .form-container-parameter {
    background: #f3f3f3;
    padding: 20px 20px 0 0;
  }
</style>
